<template>
  <div>
    <div>
      <storeform @search="search" @adds="adds"/>
    </div>
    <Divider />
    <div>
      <Table
        border
        highlight-row
        :loading="loading"
        stripe
        :columns="columns1"
        :data="data1"
        height="700"
      ></Table>
    </div>
  </div>
</template>
<script>
import storeform from "../from/storechart.vue";
export default {
  data: function () {
    return {
      loading: true,
      show: true,
      columns1: [
        {
          title: "ID",
          key: "sid",
        },
        {
          title: "仓库名称",
          key: "name",
        },
        {
          title: "现有量",
          key: "nv",
        },
        {
          title: "总量",
          key: "tv",
        },
        {
          title: "位置",
          key: "position",
        },
        {
          title: "修建时间",
          key: "builddate",
        },
        {
          title: "仓库类型",
          key: "type",
        },
      ],
      data1: this.datas,
    };
  },
  components: {
    storeform,
  },
  mounted() {
    this.axios
      .get("/api/store")
      .then((r) => {
        this.data1 = r.data;
        this.loading = false;
      })
      .catch((e) => {
        this.$Message.error("e" + e);
      });
  },
  methods: {
    search(data){
      this.axios.get('/api/store',{params:{param:data}}).then((r)=>{
        this.data1=r.data
      }).catch((e)=>{
        this.$Message.error("e"+e)
      })
    },
    adds(data){
      this.axios.post('/api/store',data).then(()=>{
        this.$Message.info("添加成功")
      }).catch((e)=>{
        this.$Message.error("E"+e)
      })
    }
  },
};
</script>

<style>
</style>